package org.xtremeobjects.workbech.rcp;

import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.eclipse.ui.PartInitException;
import org.xtremeobjects.forms.ui.editors.ObjectEditor;

public class OpenObjectEditorAction implements IWorkbenchWindowActionDelegate {

	private IWorkbenchWindow window;
	
	public OpenObjectEditorAction()
	{
	}
	

	public void dispose() {
		// TODO Auto-generated method stub
		
	}

	public void init(IWorkbenchWindow window) {
		this.window = window;
	}

	public void run(IAction action) {
		if(window != null) {	
			try {
				window.getActivePage().openEditor(new XObjectEditorInput(), ObjectEditor.ID);
			} catch (PartInitException e) {
				MessageDialog.openError(window.getShell(), "Error", "Error opening view:" + e.getMessage());
			}
		}
	}

	public void selectionChanged(IAction action, ISelection selection) {
		
	}
}
